package com.nommon.menu;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;


public class Background {
	
	private Bitmap bitmap;
	private int pos;

	public Background(Bitmap bitmap) {
		this.bitmap = bitmap;
		pos = 0;
	}

	public void onUpdate(float deltaSec) {
		pos++;
	}

	public void draw(Canvas canvas) {
		if (pos >= 0){
			pos = -bitmap.getHeight()+canvas.getHeight();
		}
		Matrix m = new Matrix();
		m.setTranslate(0, pos);
		m.postScale(1f * canvas.getWidth() / bitmap.getWidth(), 1);
		canvas.drawBitmap(bitmap, m, null);
	}

}
